#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#include<stdlib.h>

int* masterMind(char* solution, char* guess, int* returnSize);

int main()
{
    char* solution = "GRRR";
    char* guess = "RBYB";

    int returnSize;
    int* ret = masterMind(solution, guess, &returnSize);

    printf("%d %d", ret[0], ret[1]);

    free(ret);

    return 0;
}

int* masterMind(char* solution, char* guess, int* returnSize) {
    *returnSize = 2;
    int* ret = malloc(sizeof(int) * 2);
    int realguess = 0, fakeguess = 0, totalguess = 0;

    int i, j, k;
    for (i = 0; i < 4; i++)
    {
        if (solution[i] == guess[i])
        {
            realguess++;
        }
    }

    for (i = 0; i < 4; i++)
    {
        for (j = 0; j < 4; j++)
        {
            if (solution[i] == guess[j])
            {
                totalguess++;
                for (k = i + 1; k < 4; k++)
                {
                    if (solution[k] == solution[i]);
                    {
                        solution[k] = 'P';
                    }
                }
                break;
            }
        }
    }

    fakeguess = totalguess - realguess;

    ret[0] = realguess;
    ret[1] = fakeguess;

    return ret;
}

